{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "db43ca34",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "pd.set_option('display.max_columns', None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "88999cee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990/12/19</td>\n",
       "      <td></td>\n",
       "      <td>96.050</td>\n",
       "      <td>99.980</td>\n",
       "      <td>95.790</td>\n",
       "      <td>99.980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990/12/20</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.300</td>\n",
       "      <td>104.390</td>\n",
       "      <td>99.980</td>\n",
       "      <td>104.390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990/12/21</td>\n",
       "      <td>104.39</td>\n",
       "      <td>109.070</td>\n",
       "      <td>109.130</td>\n",
       "      <td>103.730</td>\n",
       "      <td>109.130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990/12/24</td>\n",
       "      <td>109.13</td>\n",
       "      <td>113.570</td>\n",
       "      <td>114.550</td>\n",
       "      <td>109.130</td>\n",
       "      <td>114.550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1990/12/25</td>\n",
       "      <td>114.55</td>\n",
       "      <td>120.090</td>\n",
       "      <td>120.250</td>\n",
       "      <td>114.550</td>\n",
       "      <td>120.250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8468</th>\n",
       "      <td>2025/8/25</td>\n",
       "      <td>3825.759</td>\n",
       "      <td>3848.163</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3839.972</td>\n",
       "      <td>3883.562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8469</th>\n",
       "      <td>2025/8/26</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3871.471</td>\n",
       "      <td>3888.599</td>\n",
       "      <td>3859.758</td>\n",
       "      <td>3868.382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8470</th>\n",
       "      <td>2025/8/27</td>\n",
       "      <td>3868.382</td>\n",
       "      <td>3869.612</td>\n",
       "      <td>3887.198</td>\n",
       "      <td>3800.350</td>\n",
       "      <td>3800.350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8471</th>\n",
       "      <td>2025/8/28</td>\n",
       "      <td>3800.35</td>\n",
       "      <td>3796.711</td>\n",
       "      <td>3845.087</td>\n",
       "      <td>3761.422</td>\n",
       "      <td>3843.597</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8472</th>\n",
       "      <td>2025/8/29</td>\n",
       "      <td>3843.597</td>\n",
       "      <td>3842.823</td>\n",
       "      <td>3867.606</td>\n",
       "      <td>3839.206</td>\n",
       "      <td>3857.927</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8473 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             Day  Preclose      Open   Highest    Lowest     Close\n",
       "0     1990/12/19              96.050    99.980    95.790    99.980\n",
       "1     1990/12/20     99.98   104.300   104.390    99.980   104.390\n",
       "2     1990/12/21    104.39   109.070   109.130   103.730   109.130\n",
       "3     1990/12/24    109.13   113.570   114.550   109.130   114.550\n",
       "4     1990/12/25    114.55   120.090   120.250   114.550   120.250\n",
       "...          ...       ...       ...       ...       ...       ...\n",
       "8468   2025/8/25  3825.759  3848.163  3883.562  3839.972  3883.562\n",
       "8469   2025/8/26  3883.562  3871.471  3888.599  3859.758  3868.382\n",
       "8470   2025/8/27  3868.382  3869.612  3887.198  3800.350  3800.350\n",
       "8471   2025/8/28   3800.35  3796.711  3845.087  3761.422  3843.597\n",
       "8472   2025/8/29  3843.597  3842.823  3867.606  3839.206  3857.927\n",
       "\n",
       "[8473 rows x 6 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock = pd.read_csv(r\"D:\\python homework\\000001.csv\") # 这一句是导入CSV文件的命令\n",
    "stock"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c46a40bf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(stock)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "efedebb4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Index(['Day', 'Preclose', 'Open', 'Highest', 'Lowest', 'Close'], dtype='object')\n"
     ]
    }
   ],
   "source": [
    "print(stock.columns)#显示所有列名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "39a2dc3b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Day' 'Preclose' 'Open' 'Highest' 'Lowest' 'Close']\n"
     ]
    }
   ],
   "source": [
    "print(stock.columns.values)#显示所有列名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "2769b6b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       1990/12/19\n",
       "1       1990/12/20\n",
       "2       1990/12/21\n",
       "3       1990/12/24\n",
       "4       1990/12/25\n",
       "           ...    \n",
       "8468     2025/8/25\n",
       "8469     2025/8/26\n",
       "8470     2025/8/27\n",
       "8471     2025/8/28\n",
       "8472     2025/8/29\n",
       "Name: Day, Length: 8473, dtype: object"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock['Day']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e7009b6e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       1990/12/19\n",
       "1       1990/12/20\n",
       "2       1990/12/21\n",
       "3       1990/12/24\n",
       "4       1990/12/25\n",
       "           ...    \n",
       "8468     2025/8/25\n",
       "8469     2025/8/26\n",
       "8470     2025/8/27\n",
       "8471     2025/8/28\n",
       "8472     2025/8/29\n",
       "Name: Day, Length: 8473, dtype: object"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock.Day#显示某一列数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "93821ed1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990/12/19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990/12/20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990/12/21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990/12/24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1990/12/25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8468</th>\n",
       "      <td>2025/8/25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8469</th>\n",
       "      <td>2025/8/26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8470</th>\n",
       "      <td>2025/8/27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8471</th>\n",
       "      <td>2025/8/28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8472</th>\n",
       "      <td>2025/8/29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8473 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             Day\n",
       "0     1990/12/19\n",
       "1     1990/12/20\n",
       "2     1990/12/21\n",
       "3     1990/12/24\n",
       "4     1990/12/25\n",
       "...          ...\n",
       "8468   2025/8/25\n",
       "8469   2025/8/26\n",
       "8470   2025/8/27\n",
       "8471   2025/8/28\n",
       "8472   2025/8/29\n",
       "\n",
       "[8473 rows x 1 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock[['Day']]#显示某一列数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e73f30c3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.series.Series"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(stock['Day'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "55318e8d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(stock[['Day']])\n",
    "#两种方式的区别：前者是Series，后者是DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "aa6bcd7f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990/12/19</td>\n",
       "      <td></td>\n",
       "      <td>96.05</td>\n",
       "      <td>99.98</td>\n",
       "      <td>95.79</td>\n",
       "      <td>99.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990/12/20</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.30</td>\n",
       "      <td>104.39</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990/12/21</td>\n",
       "      <td>104.39</td>\n",
       "      <td>109.07</td>\n",
       "      <td>109.13</td>\n",
       "      <td>103.73</td>\n",
       "      <td>109.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990/12/24</td>\n",
       "      <td>109.13</td>\n",
       "      <td>113.57</td>\n",
       "      <td>114.55</td>\n",
       "      <td>109.13</td>\n",
       "      <td>114.55</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Day  Preclose    Open  Highest  Lowest   Close\n",
       "0  1990/12/19             96.05    99.98   95.79   99.98\n",
       "1  1990/12/20     99.98  104.30   104.39   99.98  104.39\n",
       "2  1990/12/21    104.39  109.07   109.13  103.73  109.13\n",
       "3  1990/12/24    109.13  113.57   114.55  109.13  114.55"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock[0:4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "a975b2ca",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990/12/19</td>\n",
       "      <td></td>\n",
       "      <td>96.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990/12/20</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990/12/21</td>\n",
       "      <td>104.39</td>\n",
       "      <td>109.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990/12/24</td>\n",
       "      <td>109.13</td>\n",
       "      <td>113.57</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Day  Preclose    Open\n",
       "0  1990/12/19             96.05\n",
       "1  1990/12/20     99.98  104.30\n",
       "2  1990/12/21    104.39  109.07\n",
       "3  1990/12/24    109.13  113.57"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock.iloc[0:4, 0:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "a111c961",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "109.13"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock.at[3,'Lowest']#通过行标签和列标签来选取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ac5d2615",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3    109.13\n",
       "Name: Preclose, dtype: object"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock[stock['Day'] == \"1990/12/24\"].Preclose"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "01e587f4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990-12-19</td>\n",
       "      <td></td>\n",
       "      <td>96.050</td>\n",
       "      <td>99.980</td>\n",
       "      <td>95.790</td>\n",
       "      <td>99.980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990-12-20</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.300</td>\n",
       "      <td>104.390</td>\n",
       "      <td>99.980</td>\n",
       "      <td>104.390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990-12-21</td>\n",
       "      <td>104.39</td>\n",
       "      <td>109.070</td>\n",
       "      <td>109.130</td>\n",
       "      <td>103.730</td>\n",
       "      <td>109.130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990-12-24</td>\n",
       "      <td>109.13</td>\n",
       "      <td>113.570</td>\n",
       "      <td>114.550</td>\n",
       "      <td>109.130</td>\n",
       "      <td>114.550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1990-12-25</td>\n",
       "      <td>114.55</td>\n",
       "      <td>120.090</td>\n",
       "      <td>120.250</td>\n",
       "      <td>114.550</td>\n",
       "      <td>120.250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8468</th>\n",
       "      <td>2025-08-25</td>\n",
       "      <td>3825.759</td>\n",
       "      <td>3848.163</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3839.972</td>\n",
       "      <td>3883.562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8469</th>\n",
       "      <td>2025-08-26</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3871.471</td>\n",
       "      <td>3888.599</td>\n",
       "      <td>3859.758</td>\n",
       "      <td>3868.382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8470</th>\n",
       "      <td>2025-08-27</td>\n",
       "      <td>3868.382</td>\n",
       "      <td>3869.612</td>\n",
       "      <td>3887.198</td>\n",
       "      <td>3800.350</td>\n",
       "      <td>3800.350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8471</th>\n",
       "      <td>2025-08-28</td>\n",
       "      <td>3800.35</td>\n",
       "      <td>3796.711</td>\n",
       "      <td>3845.087</td>\n",
       "      <td>3761.422</td>\n",
       "      <td>3843.597</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8472</th>\n",
       "      <td>2025-08-29</td>\n",
       "      <td>3843.597</td>\n",
       "      <td>3842.823</td>\n",
       "      <td>3867.606</td>\n",
       "      <td>3839.206</td>\n",
       "      <td>3857.927</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8473 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            Day  Preclose      Open   Highest    Lowest     Close\n",
       "0    1990-12-19              96.050    99.980    95.790    99.980\n",
       "1    1990-12-20     99.98   104.300   104.390    99.980   104.390\n",
       "2    1990-12-21    104.39   109.070   109.130   103.730   109.130\n",
       "3    1990-12-24    109.13   113.570   114.550   109.130   114.550\n",
       "4    1990-12-25    114.55   120.090   120.250   114.550   120.250\n",
       "...         ...       ...       ...       ...       ...       ...\n",
       "8468 2025-08-25  3825.759  3848.163  3883.562  3839.972  3883.562\n",
       "8469 2025-08-26  3883.562  3871.471  3888.599  3859.758  3868.382\n",
       "8470 2025-08-27  3868.382  3869.612  3887.198  3800.350  3800.350\n",
       "8471 2025-08-28   3800.35  3796.711  3845.087  3761.422  3843.597\n",
       "8472 2025-08-29  3843.597  3842.823  3867.606  3839.206  3857.927\n",
       "\n",
       "[8473 rows x 6 columns]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock['Day'] = pd.to_datetime(stock['Day'],format='%y/%m/%d') #将字符串格式的日期转换为日期格式\n",
    "stock"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ea851350",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method set_index in module pandas.core.frame:\n",
      "\n",
      "set_index(keys, *, drop: 'bool' = True, append: 'bool' = False, inplace: 'bool' = False, verify_integrity: 'bool' = False) -> 'DataFrame | None' method of pandas.core.frame.DataFrame instance\n",
      "    Set the DataFrame index using existing columns.\n",
      "\n",
      "    Set the DataFrame index (row labels) using one or more existing\n",
      "    columns or arrays (of the correct length). The index can replace the\n",
      "    existing index or expand on it.\n",
      "\n",
      "    Parameters\n",
      "    ----------\n",
      "    keys : label or array-like or list of labels/arrays\n",
      "        This parameter can be either a single column key, a single array of\n",
      "        the same length as the calling DataFrame, or a list containing an\n",
      "        arbitrary combination of column keys and arrays. Here, \"array\"\n",
      "        encompasses :class:`Series`, :class:`Index`, ``np.ndarray``, and\n",
      "        instances of :class:`~collections.abc.Iterator`.\n",
      "    drop : bool, default True\n",
      "        Delete columns to be used as the new index.\n",
      "    append : bool, default False\n",
      "        Whether to append columns to existing index.\n",
      "    inplace : bool, default False\n",
      "        Whether to modify the DataFrame rather than creating a new one.\n",
      "    verify_integrity : bool, default False\n",
      "        Check the new index for duplicates. Otherwise defer the check until\n",
      "        necessary. Setting to False will improve the performance of this\n",
      "        method.\n",
      "\n",
      "    Returns\n",
      "    -------\n",
      "    DataFrame or None\n",
      "        Changed row labels or None if ``inplace=True``.\n",
      "\n",
      "    See Also\n",
      "    --------\n",
      "    DataFrame.reset_index : Opposite of set_index.\n",
      "    DataFrame.reindex : Change to new indices or expand indices.\n",
      "    DataFrame.reindex_like : Change to same indices as other DataFrame.\n",
      "\n",
      "    Examples\n",
      "    --------\n",
      "    >>> df = pd.DataFrame({'month': [1, 4, 7, 10],\n",
      "    ...                    'year': [2012, 2014, 2013, 2014],\n",
      "    ...                    'sale': [55, 40, 84, 31]})\n",
      "    >>> df\n",
      "       month  year  sale\n",
      "    0      1  2012    55\n",
      "    1      4  2014    40\n",
      "    2      7  2013    84\n",
      "    3     10  2014    31\n",
      "\n",
      "    Set the index to become the 'month' column:\n",
      "\n",
      "    >>> df.set_index('month')\n",
      "           year  sale\n",
      "    month\n",
      "    1      2012    55\n",
      "    4      2014    40\n",
      "    7      2013    84\n",
      "    10     2014    31\n",
      "\n",
      "    Create a MultiIndex using columns 'year' and 'month':\n",
      "\n",
      "    >>> df.set_index(['year', 'month'])\n",
      "                sale\n",
      "    year  month\n",
      "    2012  1     55\n",
      "    2014  4     40\n",
      "    2013  7     84\n",
      "    2014  10    31\n",
      "\n",
      "    Create a MultiIndex using an Index and a column:\n",
      "\n",
      "    >>> df.set_index([pd.Index([1, 2, 3, 4]), 'year'])\n",
      "             month  sale\n",
      "       year\n",
      "    1  2012  1      55\n",
      "    2  2014  4      40\n",
      "    3  2013  7      84\n",
      "    4  2014  10     31\n",
      "\n",
      "    Create a MultiIndex using two Series:\n",
      "\n",
      "    >>> s = pd.Series([1, 2, 3, 4])\n",
      "    >>> df.set_index([s, s**2])\n",
      "          month  year  sale\n",
      "    1 1       1  2012    55\n",
      "    2 4       4  2014    40\n",
      "    3 9       7  2013    84\n",
      "    4 16     10  2014    31\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(stock.set_index)#查看函数帮助文档"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bccbb475",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Day</th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1990-12-19</td>\n",
       "      <td></td>\n",
       "      <td>96.050</td>\n",
       "      <td>99.980</td>\n",
       "      <td>95.790</td>\n",
       "      <td>99.980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1990-12-20</td>\n",
       "      <td>99.98</td>\n",
       "      <td>104.300</td>\n",
       "      <td>104.390</td>\n",
       "      <td>99.980</td>\n",
       "      <td>104.390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1990-12-21</td>\n",
       "      <td>104.39</td>\n",
       "      <td>109.070</td>\n",
       "      <td>109.130</td>\n",
       "      <td>103.730</td>\n",
       "      <td>109.130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1990-12-24</td>\n",
       "      <td>109.13</td>\n",
       "      <td>113.570</td>\n",
       "      <td>114.550</td>\n",
       "      <td>109.130</td>\n",
       "      <td>114.550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1990-12-25</td>\n",
       "      <td>114.55</td>\n",
       "      <td>120.090</td>\n",
       "      <td>120.250</td>\n",
       "      <td>114.550</td>\n",
       "      <td>120.250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8468</th>\n",
       "      <td>2025-08-25</td>\n",
       "      <td>3825.759</td>\n",
       "      <td>3848.163</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3839.972</td>\n",
       "      <td>3883.562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8469</th>\n",
       "      <td>2025-08-26</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3871.471</td>\n",
       "      <td>3888.599</td>\n",
       "      <td>3859.758</td>\n",
       "      <td>3868.382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8470</th>\n",
       "      <td>2025-08-27</td>\n",
       "      <td>3868.382</td>\n",
       "      <td>3869.612</td>\n",
       "      <td>3887.198</td>\n",
       "      <td>3800.350</td>\n",
       "      <td>3800.350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8471</th>\n",
       "      <td>2025-08-28</td>\n",
       "      <td>3800.35</td>\n",
       "      <td>3796.711</td>\n",
       "      <td>3845.087</td>\n",
       "      <td>3761.422</td>\n",
       "      <td>3843.597</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8472</th>\n",
       "      <td>2025-08-29</td>\n",
       "      <td>3843.597</td>\n",
       "      <td>3842.823</td>\n",
       "      <td>3867.606</td>\n",
       "      <td>3839.206</td>\n",
       "      <td>3857.927</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8473 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            Day  Preclose      Open   Highest    Lowest     Close\n",
       "0    1990-12-19              96.050    99.980    95.790    99.980\n",
       "1    1990-12-20     99.98   104.300   104.390    99.980   104.390\n",
       "2    1990-12-21    104.39   109.070   109.130   103.730   109.130\n",
       "3    1990-12-24    109.13   113.570   114.550   109.130   114.550\n",
       "4    1990-12-25    114.55   120.090   120.250   114.550   120.250\n",
       "...         ...       ...       ...       ...       ...       ...\n",
       "8468 2025-08-25  3825.759  3848.163  3883.562  3839.972  3883.562\n",
       "8469 2025-08-26  3883.562  3871.471  3888.599  3859.758  3868.382\n",
       "8470 2025-08-27  3868.382  3869.612  3887.198  3800.350  3800.350\n",
       "8471 2025-08-28   3800.35  3796.711  3845.087  3761.422  3843.597\n",
       "8472 2025-08-29  3843.597  3842.823  3867.606  3839.206  3857.927\n",
       "\n",
       "[8473 rows x 6 columns]"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock.sort_values(by = ['Day'],ascending=True)#按日期升序排列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c957a70e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Day</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1990-12-19</th>\n",
       "      <td></td>\n",
       "      <td>96.050</td>\n",
       "      <td>99.980</td>\n",
       "      <td>95.790</td>\n",
       "      <td>99.980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1990-12-20</th>\n",
       "      <td>99.98</td>\n",
       "      <td>104.300</td>\n",
       "      <td>104.390</td>\n",
       "      <td>99.980</td>\n",
       "      <td>104.390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1990-12-21</th>\n",
       "      <td>104.39</td>\n",
       "      <td>109.070</td>\n",
       "      <td>109.130</td>\n",
       "      <td>103.730</td>\n",
       "      <td>109.130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1990-12-24</th>\n",
       "      <td>109.13</td>\n",
       "      <td>113.570</td>\n",
       "      <td>114.550</td>\n",
       "      <td>109.130</td>\n",
       "      <td>114.550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1990-12-25</th>\n",
       "      <td>114.55</td>\n",
       "      <td>120.090</td>\n",
       "      <td>120.250</td>\n",
       "      <td>114.550</td>\n",
       "      <td>120.250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-25</th>\n",
       "      <td>3825.759</td>\n",
       "      <td>3848.163</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3839.972</td>\n",
       "      <td>3883.562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-26</th>\n",
       "      <td>3883.562</td>\n",
       "      <td>3871.471</td>\n",
       "      <td>3888.599</td>\n",
       "      <td>3859.758</td>\n",
       "      <td>3868.382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-27</th>\n",
       "      <td>3868.382</td>\n",
       "      <td>3869.612</td>\n",
       "      <td>3887.198</td>\n",
       "      <td>3800.350</td>\n",
       "      <td>3800.350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-28</th>\n",
       "      <td>3800.35</td>\n",
       "      <td>3796.711</td>\n",
       "      <td>3845.087</td>\n",
       "      <td>3761.422</td>\n",
       "      <td>3843.597</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-29</th>\n",
       "      <td>3843.597</td>\n",
       "      <td>3842.823</td>\n",
       "      <td>3867.606</td>\n",
       "      <td>3839.206</td>\n",
       "      <td>3857.927</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8473 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            Preclose      Open   Highest    Lowest     Close\n",
       "Day                                                         \n",
       "1990-12-19              96.050    99.980    95.790    99.980\n",
       "1990-12-20     99.98   104.300   104.390    99.980   104.390\n",
       "1990-12-21    104.39   109.070   109.130   103.730   109.130\n",
       "1990-12-24    109.13   113.570   114.550   109.130   114.550\n",
       "1990-12-25    114.55   120.090   120.250   114.550   120.250\n",
       "...              ...       ...       ...       ...       ...\n",
       "2025-08-25  3825.759  3848.163  3883.562  3839.972  3883.562\n",
       "2025-08-26  3883.562  3871.471  3888.599  3859.758  3868.382\n",
       "2025-08-27  3868.382  3869.612  3887.198  3800.350  3800.350\n",
       "2025-08-28   3800.35  3796.711  3845.087  3761.422  3843.597\n",
       "2025-08-29  3843.597  3842.823  3867.606  3839.206  3857.927\n",
       "\n",
       "[8473 rows x 5 columns]"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock.set_index('Day', inplace=True)#将日期列设置为索引列\n",
    "stock"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2bf29592",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Day</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2025-07-21</th>\n",
       "      <td>3534.483</td>\n",
       "      <td>3542.816</td>\n",
       "      <td>3560.629</td>\n",
       "      <td>3542.568</td>\n",
       "      <td>3559.791</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-22</th>\n",
       "      <td>3559.791</td>\n",
       "      <td>3561.632</td>\n",
       "      <td>3584.719</td>\n",
       "      <td>3547.252</td>\n",
       "      <td>3581.861</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-23</th>\n",
       "      <td>3581.861</td>\n",
       "      <td>3588.878</td>\n",
       "      <td>3613.022</td>\n",
       "      <td>3577.594</td>\n",
       "      <td>3582.298</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-24</th>\n",
       "      <td>3582.298</td>\n",
       "      <td>3578.912</td>\n",
       "      <td>3608.728</td>\n",
       "      <td>3577.113</td>\n",
       "      <td>3605.727</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-25</th>\n",
       "      <td>3605.727</td>\n",
       "      <td>3604.451</td>\n",
       "      <td>3610.029</td>\n",
       "      <td>3586.220</td>\n",
       "      <td>3593.655</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-28</th>\n",
       "      <td>3593.655</td>\n",
       "      <td>3594.231</td>\n",
       "      <td>3606.274</td>\n",
       "      <td>3582.149</td>\n",
       "      <td>3597.937</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-29</th>\n",
       "      <td>3597.937</td>\n",
       "      <td>3595.810</td>\n",
       "      <td>3611.353</td>\n",
       "      <td>3585.944</td>\n",
       "      <td>3609.711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-30</th>\n",
       "      <td>3609.711</td>\n",
       "      <td>3608.354</td>\n",
       "      <td>3636.166</td>\n",
       "      <td>3593.734</td>\n",
       "      <td>3615.717</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-31</th>\n",
       "      <td>3615.717</td>\n",
       "      <td>3604.696</td>\n",
       "      <td>3606.374</td>\n",
       "      <td>3562.607</td>\n",
       "      <td>3573.208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-01</th>\n",
       "      <td>3573.208</td>\n",
       "      <td>3568.261</td>\n",
       "      <td>3581.746</td>\n",
       "      <td>3550.043</td>\n",
       "      <td>3559.952</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-04</th>\n",
       "      <td>3559.952</td>\n",
       "      <td>3547.163</td>\n",
       "      <td>3583.309</td>\n",
       "      <td>3547.163</td>\n",
       "      <td>3583.309</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-05</th>\n",
       "      <td>3583.309</td>\n",
       "      <td>3588.808</td>\n",
       "      <td>3617.598</td>\n",
       "      <td>3586.969</td>\n",
       "      <td>3617.598</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-06</th>\n",
       "      <td>3617.598</td>\n",
       "      <td>3615.808</td>\n",
       "      <td>3634.314</td>\n",
       "      <td>3613.989</td>\n",
       "      <td>3633.995</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-07</th>\n",
       "      <td>3633.995</td>\n",
       "      <td>3637.781</td>\n",
       "      <td>3645.117</td>\n",
       "      <td>3622.522</td>\n",
       "      <td>3639.667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-08</th>\n",
       "      <td>3639.667</td>\n",
       "      <td>3634.855</td>\n",
       "      <td>3645.367</td>\n",
       "      <td>3625.451</td>\n",
       "      <td>3635.128</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Preclose      Open   Highest    Lowest     Close\n",
       "Day                                                         \n",
       "2025-07-21  3534.483  3542.816  3560.629  3542.568  3559.791\n",
       "2025-07-22  3559.791  3561.632  3584.719  3547.252  3581.861\n",
       "2025-07-23  3581.861  3588.878  3613.022  3577.594  3582.298\n",
       "2025-07-24  3582.298  3578.912  3608.728  3577.113  3605.727\n",
       "2025-07-25  3605.727  3604.451  3610.029  3586.220  3593.655\n",
       "2025-07-28  3593.655  3594.231  3606.274  3582.149  3597.937\n",
       "2025-07-29  3597.937  3595.810  3611.353  3585.944  3609.711\n",
       "2025-07-30  3609.711  3608.354  3636.166  3593.734  3615.717\n",
       "2025-07-31  3615.717  3604.696  3606.374  3562.607  3573.208\n",
       "2025-08-01  3573.208  3568.261  3581.746  3550.043  3559.952\n",
       "2025-08-04  3559.952  3547.163  3583.309  3547.163  3583.309\n",
       "2025-08-05  3583.309  3588.808  3617.598  3586.969  3617.598\n",
       "2025-08-06  3617.598  3615.808  3634.314  3613.989  3633.995\n",
       "2025-08-07  3633.995  3637.781  3645.117  3622.522  3639.667\n",
       "2025-08-08  3639.667  3634.855  3645.367  3625.451  3635.128"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock['2025-07-20':'2025-08-10']#通过索引选取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cd46dea2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Preclose</th>\n",
       "      <th>Open</th>\n",
       "      <th>Highest</th>\n",
       "      <th>Lowest</th>\n",
       "      <th>Close</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Day</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2025-07-01</th>\n",
       "      <td>3444.426</td>\n",
       "      <td>3445.846</td>\n",
       "      <td>3459.587</td>\n",
       "      <td>3441.038</td>\n",
       "      <td>3457.747</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-02</th>\n",
       "      <td>3457.747</td>\n",
       "      <td>3458.171</td>\n",
       "      <td>3461.328</td>\n",
       "      <td>3447.956</td>\n",
       "      <td>3454.792</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-03</th>\n",
       "      <td>3454.792</td>\n",
       "      <td>3456.152</td>\n",
       "      <td>3463.620</td>\n",
       "      <td>3446.974</td>\n",
       "      <td>3461.151</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-04</th>\n",
       "      <td>3461.151</td>\n",
       "      <td>3459.592</td>\n",
       "      <td>3497.225</td>\n",
       "      <td>3455.494</td>\n",
       "      <td>3472.319</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-07</th>\n",
       "      <td>3472.319</td>\n",
       "      <td>3467.985</td>\n",
       "      <td>3474.801</td>\n",
       "      <td>3462.792</td>\n",
       "      <td>3473.127</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-08</th>\n",
       "      <td>3473.127</td>\n",
       "      <td>3474.632</td>\n",
       "      <td>3499.886</td>\n",
       "      <td>3474.632</td>\n",
       "      <td>3497.475</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-09</th>\n",
       "      <td>3497.475</td>\n",
       "      <td>3498.724</td>\n",
       "      <td>3512.669</td>\n",
       "      <td>3491.201</td>\n",
       "      <td>3493.050</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-10</th>\n",
       "      <td>3493.05</td>\n",
       "      <td>3491.497</td>\n",
       "      <td>3526.590</td>\n",
       "      <td>3491.497</td>\n",
       "      <td>3509.682</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-11</th>\n",
       "      <td>3509.682</td>\n",
       "      <td>3511.366</td>\n",
       "      <td>3555.218</td>\n",
       "      <td>3506.799</td>\n",
       "      <td>3510.177</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-14</th>\n",
       "      <td>3510.177</td>\n",
       "      <td>3513.252</td>\n",
       "      <td>3532.118</td>\n",
       "      <td>3513.252</td>\n",
       "      <td>3519.650</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-15</th>\n",
       "      <td>3519.65</td>\n",
       "      <td>3519.805</td>\n",
       "      <td>3527.038</td>\n",
       "      <td>3483.380</td>\n",
       "      <td>3504.999</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-16</th>\n",
       "      <td>3504.999</td>\n",
       "      <td>3502.899</td>\n",
       "      <td>3511.806</td>\n",
       "      <td>3489.137</td>\n",
       "      <td>3503.777</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-17</th>\n",
       "      <td>3503.777</td>\n",
       "      <td>3500.372</td>\n",
       "      <td>3517.285</td>\n",
       "      <td>3499.186</td>\n",
       "      <td>3516.826</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-18</th>\n",
       "      <td>3516.826</td>\n",
       "      <td>3519.475</td>\n",
       "      <td>3536.014</td>\n",
       "      <td>3518.231</td>\n",
       "      <td>3534.483</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-21</th>\n",
       "      <td>3534.483</td>\n",
       "      <td>3542.816</td>\n",
       "      <td>3560.629</td>\n",
       "      <td>3542.568</td>\n",
       "      <td>3559.791</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-22</th>\n",
       "      <td>3559.791</td>\n",
       "      <td>3561.632</td>\n",
       "      <td>3584.719</td>\n",
       "      <td>3547.252</td>\n",
       "      <td>3581.861</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-23</th>\n",
       "      <td>3581.861</td>\n",
       "      <td>3588.878</td>\n",
       "      <td>3613.022</td>\n",
       "      <td>3577.594</td>\n",
       "      <td>3582.298</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-24</th>\n",
       "      <td>3582.298</td>\n",
       "      <td>3578.912</td>\n",
       "      <td>3608.728</td>\n",
       "      <td>3577.113</td>\n",
       "      <td>3605.727</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-25</th>\n",
       "      <td>3605.727</td>\n",
       "      <td>3604.451</td>\n",
       "      <td>3610.029</td>\n",
       "      <td>3586.220</td>\n",
       "      <td>3593.655</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-28</th>\n",
       "      <td>3593.655</td>\n",
       "      <td>3594.231</td>\n",
       "      <td>3606.274</td>\n",
       "      <td>3582.149</td>\n",
       "      <td>3597.937</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-29</th>\n",
       "      <td>3597.937</td>\n",
       "      <td>3595.810</td>\n",
       "      <td>3611.353</td>\n",
       "      <td>3585.944</td>\n",
       "      <td>3609.711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-30</th>\n",
       "      <td>3609.711</td>\n",
       "      <td>3608.354</td>\n",
       "      <td>3636.166</td>\n",
       "      <td>3593.734</td>\n",
       "      <td>3615.717</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-07-31</th>\n",
       "      <td>3615.717</td>\n",
       "      <td>3604.696</td>\n",
       "      <td>3606.374</td>\n",
       "      <td>3562.607</td>\n",
       "      <td>3573.208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-01</th>\n",
       "      <td>3573.208</td>\n",
       "      <td>3568.261</td>\n",
       "      <td>3581.746</td>\n",
       "      <td>3550.043</td>\n",
       "      <td>3559.952</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-04</th>\n",
       "      <td>3559.952</td>\n",
       "      <td>3547.163</td>\n",
       "      <td>3583.309</td>\n",
       "      <td>3547.163</td>\n",
       "      <td>3583.309</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-05</th>\n",
       "      <td>3583.309</td>\n",
       "      <td>3588.808</td>\n",
       "      <td>3617.598</td>\n",
       "      <td>3586.969</td>\n",
       "      <td>3617.598</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-06</th>\n",
       "      <td>3617.598</td>\n",
       "      <td>3615.808</td>\n",
       "      <td>3634.314</td>\n",
       "      <td>3613.989</td>\n",
       "      <td>3633.995</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-07</th>\n",
       "      <td>3633.995</td>\n",
       "      <td>3637.781</td>\n",
       "      <td>3645.117</td>\n",
       "      <td>3622.522</td>\n",
       "      <td>3639.667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-08</th>\n",
       "      <td>3639.667</td>\n",
       "      <td>3634.855</td>\n",
       "      <td>3645.367</td>\n",
       "      <td>3625.451</td>\n",
       "      <td>3635.128</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-11</th>\n",
       "      <td>3635.128</td>\n",
       "      <td>3637.053</td>\n",
       "      <td>3656.852</td>\n",
       "      <td>3629.627</td>\n",
       "      <td>3647.547</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-12</th>\n",
       "      <td>3647.547</td>\n",
       "      <td>3647.963</td>\n",
       "      <td>3669.038</td>\n",
       "      <td>3647.963</td>\n",
       "      <td>3665.918</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-13</th>\n",
       "      <td>3665.918</td>\n",
       "      <td>3668.658</td>\n",
       "      <td>3688.628</td>\n",
       "      <td>3666.547</td>\n",
       "      <td>3683.465</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-14</th>\n",
       "      <td>3683.465</td>\n",
       "      <td>3685.522</td>\n",
       "      <td>3704.772</td>\n",
       "      <td>3662.570</td>\n",
       "      <td>3666.443</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-15</th>\n",
       "      <td>3666.443</td>\n",
       "      <td>3659.815</td>\n",
       "      <td>3702.255</td>\n",
       "      <td>3658.376</td>\n",
       "      <td>3696.771</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-18</th>\n",
       "      <td>3696.771</td>\n",
       "      <td>3712.495</td>\n",
       "      <td>3745.939</td>\n",
       "      <td>3702.380</td>\n",
       "      <td>3728.027</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-19</th>\n",
       "      <td>3728.027</td>\n",
       "      <td>3728.485</td>\n",
       "      <td>3746.669</td>\n",
       "      <td>3718.147</td>\n",
       "      <td>3727.288</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-20</th>\n",
       "      <td>3727.288</td>\n",
       "      <td>3716.685</td>\n",
       "      <td>3767.430</td>\n",
       "      <td>3704.991</td>\n",
       "      <td>3766.210</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-21</th>\n",
       "      <td>3766.21</td>\n",
       "      <td>3770.676</td>\n",
       "      <td>3787.981</td>\n",
       "      <td>3757.992</td>\n",
       "      <td>3771.099</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-22</th>\n",
       "      <td>3771.099</td>\n",
       "      <td>3772.277</td>\n",
       "      <td>3825.759</td>\n",
       "      <td>3772.277</td>\n",
       "      <td>3825.759</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-25</th>\n",
       "      <td>3825.759</td>\n",
       "      <td>3848.163</td>\n",
       "      <td>3883.562</td>\n",
       "      <td>3839.972</td>\n",
       "      <td>3883.562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-26</th>\n",
       "      <td>3883.562</td>\n",
       "      <td>3871.471</td>\n",
       "      <td>3888.599</td>\n",
       "      <td>3859.758</td>\n",
       "      <td>3868.382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-27</th>\n",
       "      <td>3868.382</td>\n",
       "      <td>3869.612</td>\n",
       "      <td>3887.198</td>\n",
       "      <td>3800.350</td>\n",
       "      <td>3800.350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-28</th>\n",
       "      <td>3800.35</td>\n",
       "      <td>3796.711</td>\n",
       "      <td>3845.087</td>\n",
       "      <td>3761.422</td>\n",
       "      <td>3843.597</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025-08-29</th>\n",
       "      <td>3843.597</td>\n",
       "      <td>3842.823</td>\n",
       "      <td>3867.606</td>\n",
       "      <td>3839.206</td>\n",
       "      <td>3857.927</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Preclose      Open   Highest    Lowest     Close\n",
       "Day                                                         \n",
       "2025-07-01  3444.426  3445.846  3459.587  3441.038  3457.747\n",
       "2025-07-02  3457.747  3458.171  3461.328  3447.956  3454.792\n",
       "2025-07-03  3454.792  3456.152  3463.620  3446.974  3461.151\n",
       "2025-07-04  3461.151  3459.592  3497.225  3455.494  3472.319\n",
       "2025-07-07  3472.319  3467.985  3474.801  3462.792  3473.127\n",
       "2025-07-08  3473.127  3474.632  3499.886  3474.632  3497.475\n",
       "2025-07-09  3497.475  3498.724  3512.669  3491.201  3493.050\n",
       "2025-07-10   3493.05  3491.497  3526.590  3491.497  3509.682\n",
       "2025-07-11  3509.682  3511.366  3555.218  3506.799  3510.177\n",
       "2025-07-14  3510.177  3513.252  3532.118  3513.252  3519.650\n",
       "2025-07-15   3519.65  3519.805  3527.038  3483.380  3504.999\n",
       "2025-07-16  3504.999  3502.899  3511.806  3489.137  3503.777\n",
       "2025-07-17  3503.777  3500.372  3517.285  3499.186  3516.826\n",
       "2025-07-18  3516.826  3519.475  3536.014  3518.231  3534.483\n",
       "2025-07-21  3534.483  3542.816  3560.629  3542.568  3559.791\n",
       "2025-07-22  3559.791  3561.632  3584.719  3547.252  3581.861\n",
       "2025-07-23  3581.861  3588.878  3613.022  3577.594  3582.298\n",
       "2025-07-24  3582.298  3578.912  3608.728  3577.113  3605.727\n",
       "2025-07-25  3605.727  3604.451  3610.029  3586.220  3593.655\n",
       "2025-07-28  3593.655  3594.231  3606.274  3582.149  3597.937\n",
       "2025-07-29  3597.937  3595.810  3611.353  3585.944  3609.711\n",
       "2025-07-30  3609.711  3608.354  3636.166  3593.734  3615.717\n",
       "2025-07-31  3615.717  3604.696  3606.374  3562.607  3573.208\n",
       "2025-08-01  3573.208  3568.261  3581.746  3550.043  3559.952\n",
       "2025-08-04  3559.952  3547.163  3583.309  3547.163  3583.309\n",
       "2025-08-05  3583.309  3588.808  3617.598  3586.969  3617.598\n",
       "2025-08-06  3617.598  3615.808  3634.314  3613.989  3633.995\n",
       "2025-08-07  3633.995  3637.781  3645.117  3622.522  3639.667\n",
       "2025-08-08  3639.667  3634.855  3645.367  3625.451  3635.128\n",
       "2025-08-11  3635.128  3637.053  3656.852  3629.627  3647.547\n",
       "2025-08-12  3647.547  3647.963  3669.038  3647.963  3665.918\n",
       "2025-08-13  3665.918  3668.658  3688.628  3666.547  3683.465\n",
       "2025-08-14  3683.465  3685.522  3704.772  3662.570  3666.443\n",
       "2025-08-15  3666.443  3659.815  3702.255  3658.376  3696.771\n",
       "2025-08-18  3696.771  3712.495  3745.939  3702.380  3728.027\n",
       "2025-08-19  3728.027  3728.485  3746.669  3718.147  3727.288\n",
       "2025-08-20  3727.288  3716.685  3767.430  3704.991  3766.210\n",
       "2025-08-21   3766.21  3770.676  3787.981  3757.992  3771.099\n",
       "2025-08-22  3771.099  3772.277  3825.759  3772.277  3825.759\n",
       "2025-08-25  3825.759  3848.163  3883.562  3839.972  3883.562\n",
       "2025-08-26  3883.562  3871.471  3888.599  3859.758  3868.382\n",
       "2025-08-27  3868.382  3869.612  3887.198  3800.350  3800.350\n",
       "2025-08-28   3800.35  3796.711  3845.087  3761.422  3843.597\n",
       "2025-08-29  3843.597  3842.823  3867.606  3839.206  3857.927"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock['2025-7':'2025-8']"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
